<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class giaovienloai_db 
	{
		public function Them($MaLoaiGiaoVien, $TenLoaiGiaoVien, $GhiChu)
		{
			$sql = "INSERT INTO `tbl_giaovienloai`(`MaLoaiGiaoVien`, `TenLoaiGiaoVien`, `GhiChu`)
					VALUES ('$MaLoaiGiaoVien', '$TenLoaiGiaoVien', '$GhiChu')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaLoaiGiaoVien)
		{
			$sql = "DELETE FROM `tbl_giaovienloai` WHERE `MaLoaiGiaoVien` = '$MaLoaiGiaoVien'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaLoaiGiaoVien, $TenLoaiGiaoVien, $GhiChu)
		{
			$sql = "UPDATE `tbl_giaovienloai`
					SET `TenLoaiGiaoVien` = '$TenLoaiGiaoVien', `GhiChu` = '$GhiChu'
					WHERE `MaLoaiGiaoVien` = '$MaLoaiGiaoVien'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaLoaiGiaoVien, $TenLoaiGiaoVien, $GhiChu)
		{
			$sql = "SELECT * FROM `tbl_giaovienloai` WHERE 1  ";
			if($MaLoaiGiaoVien != "")
				$sql .= " AND `MaLoaiGiaoVien` = '$MaLoaiGiaoVien' ";

			if($TenLoaiGiaoVien != "")
				$sql .= " AND `TenLoaiGiaoVien` = '$TenLoaiGiaoVien' ";

			if($GhiChu != "")
				$sql .= " AND `GhiChu` = '$GhiChu' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

